local s15__paoxiao = fk.CreateSkill {
  name = "s15__paoxiao",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable {
  ["s15__paoxiao"] = "咆哮",
  [":s15__paoxiao"] = "锁定技，出牌阶段，你可以多使用一张【杀】。每回合你使用第二张【杀】时，摸一张牌。",
  ["#s15__paoxiaoTrigger"] = "咆哮",
  ["$s15__paoxiao1"] = "啊~~~",
  ["$s15__paoxiao2"] = "燕人张飞在此！",
}

-- 目标修改效果：增加【杀】的使用次数限制
s15__paoxiao:addEffect('targetmod', {
  residue_func = function(self, player, skill, scope)
    if skill.trueName == "slash_skill" and player:hasSkill(self.name) and scope == Player.HistoryPhase then
      return 1 -- 允许多使用一张【杀】
    end
  end,
})

-- 卡牌使用效果：第二张【杀】时摸牌
s15__paoxiao:addEffect(fk.CardUsing, {
  name = "#s15__paoxiaoTrigger",
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target ~= player or not player:hasSkill(self.name) or data.card.trueName ~= "slash" then
      return false
    end
    local events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
      local use = e.data
      return use.from == player and use.card.trueName == "slash"
    end, Player.HistoryTurn)
    return #events == 2 and events[2].id == player.room.logic:getCurrentEvent().id
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
})

-- 刷新效果：当使用超过第一张【杀】时播放技能动画
s15__paoxiao:addEffect(fk.CardUsing, {
  can_refresh = function(self, event, target, player, data)
    return player == target and player:hasSkill(s15__paoxiao.name) and data.card.trueName == "slash"
        and not data.extraUse and player:usedCardTimes("slash", Player.HistoryPhase) > 1
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke("s15__paoxiao")
    room:doAnimate("InvokeSkill", {
      name = "paoxiao",
      player = player.id,
      skill_type = "offensive",
    })
  end,
})

return s15__paoxiao
